<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 访问器的优先级
    // Symbol是唯一的
    console.log(Symbol() === Symbol()); //false

    const DATA = Symbol();
    const user = {
        // 避免使用data来封闭属性时外部可通过user.data来修改属性
      [DATA]: { name },
      name: "小灰",
      age: 10,
      set name(value) {
        this[DATA].name = value;
      },
      get name() {
        return this[DATA].name;
      },
    };
    user.name = "小美";
    console.log(user.name);
    
  </script>
</html>
